<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
// IF admin is not logged in then it will redirect to the adminlogin page.
if(!isset($_SESSION['adminuserid']))
{
	header("location:index.php?msg=logfirst");
	die();
}


if(isset($_REQUEST['proid']) && trim($_REQUEST['proid']) != "")
{
	$proid = $_REQUEST['proid'];
	if(isset($_REQUEST['Submit']) && trim($_REQUEST['Submit']) == "Submit")
	   {
	   		$special=$_REQUEST['special'];
	   		$insert="INSERT INTO `tblprodgiftideas`  
						(`intgiftideaid`,`intprodid`)
			  			  VALUES ($special,'$proid')";
			$sql=$obj_db->insert($insert);
			header("location:product.php?msg=addtogift");
			die();
		}
}	
		
?>
<script language="javascript">

function checkfrmoffer(frm)
{
	//alert(frm);
	var val=frm.special.value;
	var strval= frm.hidoffer.value;
	strval=strval.split(",");
	for( var i=0;i<strval.length;i++)
	{
		if(val == strval[i] && val!="")
		{
			alert("You cannot select Same Offer Again.");
			return false;
		}
	}
	return true;
}
</script>
<?php include("inc/header.php");?>
<body>

 <form name="special" action="addtogift.php?proid=<?php echo $_REQUEST['proid'];?>" method="post">	
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="middlebackground">
  <tr>
    <td colspan="3" valign="top" align="center"><?php include(INC."top.inc.php");?></td>
  </tr>
  <tr>
    <td width="2%">&nbsp;</td>
    <td width="96%"><table width="60%" border="0" align="center" cellpadding="2" cellspacing="2" class="border">
      <tr class="bg1">
	  	
        <td colspan="4" align="left"><strong>Gift Idea&gt;&gt;</strong>
          <?php 
			if(isset($_REQUEST['proid']) && trim($_REQUEST['proid']) != "")
			{
				$slctd = "";
				$proid = $_REQUEST['proid'];
				$sql="select * from tblprodgiftideas where intprodid='$proid'";
				//echo $sql;
				$resman1 = $obj_db->select($sql);
				if(count($resman1)>0)
				{
					
					for($s=0;$s<count($resman1);$s++)
					{
						$giftid= $resman1[$s]['intgiftideaid'].",";
						$sql3="select * from tblideas where inttype='2' and intid='$giftid'";
						$resman3 = $obj_db->select($sql3);
							if(count($resman3)>0)
							{						
								echo $resman3[0]['vargiftideatitle'].",";
								$slctd.=$resman1[$s]['intgiftideaid'].",";
								
							}		
					}
					/*if($resman1[$s]['vargiftideatitle']==$_REQUEST['special'])
						{
							header("location:addtogift.php?msg=arst"); 
							die();
						}*/
				}
			}
	  ?> </td>
        <td align="center"><a href="#" title="Click Here to Go Back!" onClick="history.go(-1);" class="fntstyle">Go Back!</a></td>
      </tr>
		

      <tr>
        <td>&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="2%">&nbsp;</td>
        <td width="28%" align="right" class="sltimg"> Seletct Offer</td>
        <td width="3%">:</td>
        <td width="47%" align="left"><select name="special" id="special">
          <option value="0">Select Offer</option>
          <?php 
						$sql="select * from tblideas where inttype='2' and intstatus='0'";
						$resman = $obj_db->select($sql);
						if(count($resman)>0)
						{
							for($m=0;$m<count($resman);$m++)
							{
							
					?>
          <option value="<?php echo $resman[$m]['intid'];?>">
            <?php echo $resman[$m]['vargiftideatitle'];?>
            </option>
          <?php 
							}
						}
					?>
        </select></td>
        <td width="20%">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="5" align="left">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="5" align="center"><input name="Submit" type="submit" class="btn" id="Submit" value="Submit" onClick="return checkfrmoffer(this.form);"/>
          <input name="hidoffer" type="hidden" id="hidoffer" value="<?php echo $slctd;?>" /></td>
      </tr>
      <tr>
        <td colspan="5" align="center">&nbsp;</td>
      </tr>
    </table></td>
    <td width="2%">&nbsp;</td>
  </tr>
  <tr><td>&nbsp;</td></tr>
   <tr><td>&nbsp;</td></tr>
</table>
</form>
</body>
</html>
